//
//  HPSignUpViewController.m
//  HappyPenguin
//
//  Created by zhuangyihang on 1/11/16.
//  Copyright © 2016 zhuangyihang. All rights reserved.
//

#import "HPSignUpViewController.h"
#import "HPSignInTextField.h"

static const NSInteger kViewMarginTop = 100;
static const NSInteger kViewMarginLeft = 20;

static const NSInteger kTextFieldMarginTop = 5;
static const NSInteger kTextFieldHeight = 50;

static const NSInteger kSignUpMarginTop = 15;

@interface HPSignUpViewController ()

@end

@implementation HPSignUpViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupFullContentView];
    [self addBackButton:nil];
    [self setupUI];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark - Private
- (void)setupUI{
    
    UIImageView *v = [UIImageView new];
    [self.baseContentView addSubview:v];
    [v mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(self.baseContentView);
        make.center.equalTo(self.baseContentView);
    }];
    v.image = [UIImage imageNamed:@"SignIn_Background"];
    v.contentMode = UIViewContentModeCenter;
    
    HPSignInTextField *phone = [HPSignInTextField new];
    [self.baseContentView addSubview:phone];
    [phone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.baseContentView).offset(-2*kViewMarginLeft);
        make.centerX.equalTo(self.baseContentView);
        make.height.mas_equalTo(kTextFieldHeight);
        make.top.equalTo(self.baseContentView).offset(kViewMarginTop);
    }];
    [phone setImageViewHidden:YES];
    
    phone.textField.placeholder = @"输入手机号码";
    phone.textField.keyboardType = UIKeyboardTypePhonePad;
    
    HPSignInTextField *veri = [HPSignInTextField new];
    [self.baseContentView addSubview:veri];
    [veri mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.width.centerX.mas_equalTo(phone);
        make.top.equalTo(phone.mas_bottom).offset(kTextFieldMarginTop);
    }];
    [veri setImageViewHidden:YES];
    
    veri.textField.placeholder = @"输入验证码";
    veri.textField.keyboardType = UIKeyboardTypePhonePad;
    
    HPSignInTextField *pwd = [HPSignInTextField new];
    [self.baseContentView addSubview:pwd];
    [pwd mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.width.centerX.mas_equalTo(veri);
        make.top.equalTo(veri.mas_bottom).offset(kTextFieldMarginTop);
    }];
    [pwd setImageViewHidden:YES];
    
    pwd.textField.placeholder = @"设置6-16位字母和数字的密码";
    
    HPSignInTextField *repwd = [HPSignInTextField new];
    [self.baseContentView addSubview:repwd];
    [repwd mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.width.centerX.mas_equalTo(veri);
        make.top.equalTo(pwd.mas_bottom).offset(kTextFieldMarginTop);
    }];
    [repwd setImageViewHidden:YES];
    
    repwd.textField.placeholder = @"再次输入密码";
    
    
    UIButton *veriButton = [UIButton buttonWithType:UIButtonTypeCustom];
    veriButton.backgroundColor = [UIColor colorWithWhite:0.8 alpha:0.5];
    [self.baseContentView addSubview:veriButton];
    [veriButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@100);
        make.right.equalTo(veri);
        make.bottom.equalTo(veri).offset(-5);
        make.height.equalTo(@40);
    }];
    [veriButton setTitle:@"获取验证码" forState:UIControlStateNormal];
    veriButton.titleLabel.font = [UIConstants getFont:15];
    
    UIButton *signUp = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.baseContentView addSubview:signUp];
    signUp.backgroundColor = [UIColor colorWithWhite:0.9 alpha:0.1];
    [signUp setTitle:@"注 册" forState:UIControlStateNormal];
    [signUp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@40);
        make.width.equalTo(repwd);
        make.centerX.equalTo(self.baseContentView);
        make.top.equalTo(repwd.mas_bottom).offset(kSignUpMarginTop);
    }];
    signUp.titleLabel.font = [UIConstants getFont:15];
    signUp.layer.cornerRadius = 3;
}

@end
